<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
		<script>
			class RangeIterator {
				constructor(start, stop) {
					this.value = start
					this.stop = stop
				}

				[Symbol.iterator]() {
					return this
				}

				next() {
					var value = this.value
					if (value < this.stop) {
						this.value++
						return { done: false, value: value }
					}
					return { done: true, value: undefined }
				}
			}

			function range(start, stop) {
				return new RangeIterator(start, stop)
			}
            const obj = range(0, 3)
			for (var value of obj) {
				console.log(value) // 0, 1, 2
			}
		</script>
	</head>
	<body></body>
</html>
